/*
 * © Copyright 2011 Romain Marteau, Matthieu Totet
 * 
 *    This file is part of VineaToum.
 *
 *    VineaToum is free software: you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation, either version 3 of the License, or
 *    (at your option) any later version.
 *
 *    VineaToum is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *
 *    You should have received a copy of the GNU General Public License
 *    along with VineaToum.  If not, see <http://www.gnu.org/licenses/>.
 */

package org.vineatoum.business.action.operationactive;

import java.util.Date;
import java.util.Vector;

import org.vineatoum.business.Cuve;
import org.vineatoum.business.action.abstraction.ActiveOperation;
import org.vineatoum.view.utils.jtablecustom.TableListener;

public class Debourbage extends ActiveOperation {
	private final String DATE = "Date du débourbage";
	private final String QTE_BOURBE = "Quantité de bourbe";
	private final String CUVE_DESTINATION = "Cuve de destination (vin)";
	private final String CUVE_BOURBE = "Cuve bourbe";
	
	private Cuve cuveDestination;
	private Cuve cuveBourbe;
	private Float qteBourbe;
	
	public Debourbage() {
		super();
		
		date = new Date();
		qteBourbe = new Float(50);
	}

	/**
	 * @return the cuveDestination
	 */
	public Cuve getCuveDestination() {
		return cuveDestination;
	}

	/**
	 * @param cuveDestination the cuveDestination to set
	 */
	public void setCuveDestination(Cuve cuveDestination) {
		this.cuveDestination = cuveDestination;
	}

	/**
	 * @return the cuveBourbe
	 */
	public Cuve getCuveBourbe() {
		return cuveBourbe;
	}

	/**
	 * @param cuveBourbe the cuveBourbe to set
	 */
	public void setCuveBourbe(Cuve cuveBourbe) {
		this.cuveBourbe = cuveBourbe;
	}

	/**
	 * @return the qteBourbe
	 */
	public Float getQteBourbe() {
		return qteBourbe;
	}

	/**
	 * @param qteBourbe the qteBourbe to set
	 */
	public void setQteBourbe(Float qteBourbe) {
		this.qteBourbe = qteBourbe;
	}

	@Override
	public TableListener getNewInstance() {
		return new Debourbage();
	}

	@Override
	public Vector<String> getVectorColumns() {
		Vector<String> columns = new Vector<String>();
		columns.add(DATE);
		columns.add(QTE_BOURBE);
		columns.add(CUVE_DESTINATION);
		columns.add(CUVE_BOURBE);
		return columns;
	}

	@Override
	public Vector<Object> getVectorData() {
		Vector<Object> values = new Vector<Object>();
		values.add(date);
		values.add(qteBourbe);
		values.add(cuveDestination);
		values.add(cuveBourbe);
		return values;
	}

	@Override
	public void updateField(String field, Object value) {
		try {
			if(field == DATE) {
				date = (Date)value;
			} else if (field == QTE_BOURBE) {
				qteBourbe = (Float)value;
			} else if (field == CUVE_DESTINATION) {
				cuveDestination = (Cuve)value;
			} else if (field == CUVE_BOURBE) {
				cuveBourbe = (Cuve)value;
			}
		} catch (Exception e) {
			System.err.println("error parsing in Debourbage for field " + field);
			// TODO: handle exception
		}
	}
	
	

}
